define(function(require, exports, module) {
    var myPub = require('./public');
    var oShadow = $('.js_shadow'); //阴影
    // ------------------2018年3月16日17:28:36-------------------------
    //var oCoverageMain = $('.js_coverageMain'); //全额保障说明内容
    var oCoverageList = $('.js_appcoverageList'); //全额保障tag
    var otasteReportApp = $('.js_taste_report_app'); //试吃报告
    var oPlartFormAdvantageApp = $('.js_platform_advantage_app'); //平台买点
    var oTexture = $('.js_apptexture'); //口感证书
    var oImgShow = $('.js_imgShow');                                 // 内外包装展示区域
    //var oCoverage_button = $('.js_coverage_button'); //全额保障说明确定按钮
    // ------------------2018年3月16日17:28:36-------------------------

    oShadow.on("touchmove",function(e) {e.preventDefault()});


    // -----------------2018年4月25日16:30:29-------------------------------------

    //var moveHeight = oCoverageMain.outerHeight(true);
    //oCoverageMain.css({'bottom': -moveHeight });

    //显示全额保障详细内容
    /*oCoverageList.hammer().on('tap',function(e) {
        oCoverageMain.show().stop().animate({ 'bottom':0 },300,function() {
            oShadow.show();
        });
        myPub.HamstopPropaga();
        myPub.OffMuiEvent(false);
    });*/

    var param1 = false;
    var param2 = false;
    var param3 = false;
    var param4 = false;

    // 全额保障详细内容的显示内容判断，以及右上角图标选择性显示
    var promiseCon = $(".js_promise-tag li");
    //var selectTemp = [];
    var promiseDea = $(".js_coverage_quality p");
    promiseCon.each(function(i, e) {
        //selectTemp.push(e.getAttribute("data-priority"));
        if(e.getAttribute("data-priority") == "1"){
            param1 = true;
        }else if(e.getAttribute("data-priority") == "2"){
            param2 = true;
        }else if(e.getAttribute("data-priority") == "3"){
            param3 = true;
        }else if(e.getAttribute("data-priority") == "4"){
            param4 = true;
        }
    });

    var kougan = $("#kougan").html();
    var array=[];
    if(kougan != undefined){
        if(kougan.indexOf(',') == -1){
            array[0] = kougan;
        }else{
            array = kougan.split(",");
        }
    }
    oTexture.on("touchstart",function () {
        myPub.JudgeAppHide(function () {
            window.webkit.messageHandlers.TasteEvaluationModel.postMessage(array);
        },function () {
            android.popUpWindowFlavors(array);
        })
    });

    var iosParam = param1+","+param2+","+param3+","+param4;
    oCoverageList.on('touchstart',function () {
        //console.log(param1+","+param2+","+param3+","+param4);
        myPub.JudgeAppHide(function(){
            //ios
            window.webkit.messageHandlers.IndemnityModel.postMessage(iosParam);
        },function(){
            //android
            android.popUpWindow(param1, param2, param3, param4);

        });
    });

    otasteReportApp.on('click',function () {
        window.location.href = "/shop/goods/getTasteReport?goodsSn="+goodsSn+"&type=1";
    });

    oPlartFormAdvantageApp.on('click',function () {
        window.location.href = "/shop/goods/getTasteReport?goodsSn="+goodsSn+"&type=2";
    })

    // 内外包装的
    var imgUrlArr = [];
    var oImgEl = oImgShow.find('img');
    oImgEl.each(function (index,el) {
        imgUrlArr.push($(el).attr('src'))
    });
    oImgEl.on('click',function () {
        var index = oImgEl.index(this);
        var packArr = imgUrlArr.join(',');
        myPub.JudgeAppHide(function(){
            //ios
            window.webkit.messageHandlers.PackagingModel.postMessage({
                imgArr:imgUrlArr,
                index:index
            });
        },function(){
            //android
            android.PackagingModel(packArr,index);

        });
    })
});